<!-- 巡检 -->
<template>
	<view style="height: 100vh; background-color: #FFFFFF;">
		<u-navbar title-color="#FFFFFF" height="48" back-icon-color="#FFFFFF" :border-bottom="false" :is-fixed="true" :title="'巡检记录'"></u-navbar>
		<uc-content :loading="loading">
			<!--巡检记录列表页面-->
			<view v-if="InspectionLogList.length<1" class="view-center">
				<u-empty text="暂无巡检记录信息" mode="list"></u-empty>
			</view>
			<view v-else>
				<view class="list-item" v-for="(item,index) in InspectionLogList" :key="index" @click="checkItem(item)">
					<view class="list-top ">
						<view class="list-left">巡检名称:{{ item.taskName }}</view>
					</view>
					<view class="list-center u-line-3">
						<view>巡检人:{{item.userName}}</view>
						<view>巡检描述:{{item.remark}}</view>
					</view>
					<view class="list-bottom">	
					<view>巡检时间:{{item.inspectionTime|dateFormat}}</view>
					</view>
				</view>
				<u-loadmore :status="status" :icon-type="iconType" :load-text="loadText" />
			</view>
		</uc-content>
	
	</view>
</template>

<script>
	export default {
		data() {
			return {
				loading:false,
				InspectionLogList: [],
				pageNum:0,
				finished:false,
				status: 'loadmore',
				iconType: 'flower',
				loadText: {
					loadmore: '轻轻上拉',
					loading: '努力加载中',
					nomore: '没有更多数据了'
				}
			}
		},
		onLoad(e) {
			console.log(e)
			this.ucId = e.ucId
		},
		onShow() {
			this.initView()
		},
		methods: {
			initView(val) {
				this.loading=true
				this.InspectionLogList = []
				this.pageNum = 0
				this.getInInspectionLogPage()
			},
			//巡检记录信息分页查询
			getInInspectionLogPage(){
				this.pageNum++  
				let _this = this
				return new Promise((resolve, reject) => {
					_this.utils.request("/api/app/inInspectionLog/getInInspectionLogPage", {pageNum:this.pageNum,pageSize:10,equipmentId:this.ucId}, "post", "app", true).then(res => {
						console.log(res.data)
						_this.loading=false
						_this.InspectionLogList.push(...res.data.list)
						_this.finished = (res.data.pageNum >= res.data.pages);
						if(_this.finished){
							_this.loading=false
							_this.status = 'nomore';
						}
						resolve(res)
					}).catch(error => {
						reject(error)
					})
				})
			},
			onReachBottom() {
				if(this.finished) return ;
				this.status = 'loading';
				this.getInInspectionLogPage().then(res=>{
					if(this.finished) this.status = 'nomore';
					else this.status = 'loading';
				}).catch(error=>{
					this.loading=false
					this.status = 'nomore';
				})
			},
			checkItem(item){
				uni.navigateTo({
					url:"/pages/index/InspectionLog/info?ucId="+item.ucId
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	@import "@/uview-ui/libs/css/style.components.scss";

	.list-item {
		padding: 30rpx 40rpx;
		background-color: #fff;
		border-bottom: #999999 1px solid;

		.list-top {
			@include vue-flex;
			justify-content: space-between;
			align-items: center;

			.list-left {
				font-weight: bold;
				font-size: 34rpx;
			}

			.list-right {
				font-size: 30rpx;
				line-height: 34rpx;
				color: #999999;
			}
		}

		.list-center {
			margin-top: 20rpx;
			font-size: 28rpx;
			color: #999999;
		}

		.list-bottom {
			display: flex;
			margin-top: 20rpx;
			font-size: 28rpx;
			justify-content: space-between;
			color: #999999;
		}
	}
</style>
